Preorder, Postorder and Inorder Traversal of a Binary Tree using a single Stack
Given a binary tree, the task is to print all the nodes of the binary tree in Pre-order, Post-order, and In-order iteratively using only one stack traversal....
read more
Basic Operations on Binary Tree with Implementations
The tree is a hierarchical Data Structure. A binary tree is a tree that has at most two children. The node which is on the left of the Binary Tree is called “Left-Child” and the node which is the right is called “Right-Child”. Also, the smaller tree or the subtree in the left of the root node is called the “Left sub-tree” and that is on the right is called “Right sub-tree”....
read more
Tree Traversal Techniques – Data Structure and Algorithm Tutorials
Tree Traversal techniques include various ways to visit all the nodes of the tree. Unlike linear data structures (Array, Linked List, Queues, Stacks, etc) which have only one logical way to traverse them, trees can be traversed in different ways. In this article, we will discuss about all the tree traversal techniques along with their uses....
read more
Sudo Placement[1.4] | Jumping the Subtree
Given a binary search tree of n nodes with distinct values. Also given are Q queries. Each query consists of a node value that has to be searched in the BST and skip the subtree that has given node as its root. If the provided node is the root itself then print “Empty” without quotes. After that print the preorder traversal of the BST....
read more
Modify Binary Tree by replacing each node with the product of all remaining nodes
Given a Binary Tree consisting of N nodes, the task is to replace each node of the tree with the product of all the remaining nodes....
read more
Print all root-to-leaf paths with maximum count of even nodes
Given a Binary tree, the task is to print all possible root-to-leaf paths having a maximum number of even valued nodes....
read more
Check if given Generic N-ary Tree is Symmetric horizontally
Given an N-ary tree root, the task is to check if it is symmetric horizontally (Mirror image of itself)....
read more
Find maximum GCD value from root to leaf in a Binary tree
Given a Binary Tree, the task is to find the maximum value of GCD from any path from the root node to the leaf node....
read more
Find direction of path followed from root by a linked list in a Binary Tree
Given root of the Binary Tree T and a linked list L, the task is to find the direction of path followed from root such that there exists a path from root to any leaf node of the Tree such that the values is that path forms the Linked List. If there doesn’t exist any such path then print “-1”....
read more
Construct Tree from given Inorder and Preorder traversals
Let us consider the below traversals:...
read more
Modify Binary Tree by replacing each node with the sum of its Preorder Predecessor and Successor
Given a binary tree consisting of N nodes, the task is to replace each node in the binary tree with the sum of its preorder predecessor and preorder successor....
read more
Mix Order Traversal of a Binary Tree
Given a Binary Tree consisting of N nodes, the task is to print its Mix Order Traversal....
read more